package net.csdra.libraryborrowing.service.user;

import net.csdra.libraryborrowing.domain.user.UserBorrow;
import net.csdra.libraryborrowing.service.book.BookServiceBAT;

import java.nio.file.AccessDeniedException;
import java.util.Date;

/**
 * Created by msf on 2017/10/16.
 */
public interface UserBorrowService {
    /**
     * 续借副本。
     * 副本状态必须为外借，userBorrowId必须属于当前用户，UserBorrow的结束时间必须晚于当前时间。并生成UserBorrowLog
     * UserBorrow的状态必须为BORROWING或OVERDUE
     *
     * @param redecorate
     * @return
     */
    public UserBorrow redecorate(Redecorate redecorate) throws AccessDeniedException;


    /**
     * 处理转借信息
     * 根据transferBorrowInfoId获取TransferBorrowInfo，TransferBorrowInfo的targetUserId必须为当前用户Id，TransferBorrowInfo的state必须为READY
     * 创建当前用户的UserBorrow和UserBorrowLog
     *
     * @param handleTransferBorrowInfo
     * @return
     */
    public UserBorrow handleTransferBorrowInfo(HandleTransferBorrowInfo handleTransferBorrowInfo) throws AccessDeniedException;

    class HandleTransferBorrowInfo {
        String transferBorrowInfoId;

        public String getTransferBorrowInfoId() {
            return transferBorrowInfoId;
        }

        public void setTransferBorrowInfoId(String transferBorrowInfoId) {
            this.transferBorrowInfoId = transferBorrowInfoId;
        }
    }

    class Redecorate {
        String userBorrowId;
        //续借时间
        Date redecorateDate;
        String remark;

        public Date getRedecorateDate() {
            return redecorateDate;
        }

        public void setRedecorateDate(Date redecorateDate) {
            this.redecorateDate = redecorateDate;
        }

        public String getRemark() {
            return remark;
        }

        public void setRemark(String remark) {
            this.remark = remark;
        }

        public String getUserBorrowId() {
            return userBorrowId;
        }

        public void setUserBorrowId(String userBorrowId) {
            this.userBorrowId = userBorrowId;
        }
    }
}
